<template>
  <div class="web">
    <div class="webLeft">
      <menuleft
        :menuList="menuList"
        @handleMenu="handleMenu"
        :menuFlag="menuFlag"
      />
    </div>
    <div class="webRight">
      <systemstation
        v-show="
          menuFlag == 23 || menuFlag == 24 || menuFlag == 25 || menuFlag == 36
        "
        :menuFlag="menuFlag"
      />
      <!-- 以下27 32写在下面 不走上面组件! -->

      <document-setting v-show="menuFlag == 27" />
      <plateMent v-show="menuFlag == 26" />
      <suggestion v-show="menuFlag == 32" />
      <ExchangeSetting v-show="menuFlag == 29" />
      <StageSetting v-show="menuFlag == 31" />
    </div>
  </div>
</template>
<script>
import systemstation from "./systemStation";
import plateMent from "@/views/page/project/plateMent"; //板块管理
import DocumentSetting from "./components/DocumentSetting";
import menuleft from "@/components/menuItem/menuleft.vue";
import { getUserAuthResourceList, getRoleResourceList } from "@/service/Api.js";
import Suggestion from "./components/suggestion";
import ExchangeSetting from "./components/exchangeSetting";
import StageSetting from "./components/stageSetting";

import bus from "@/components/bus.js";

import { mapState } from "vuex";
export default {
  components: {
    DocumentSetting,
    systemstation,
    menuleft,
    plateMent,
    Suggestion,
    ExchangeSetting,
    StageSetting,
  },
  name: "systemMent",
  data() {
    return {
      menuList: [
        {
          name: "系统设置",
          id: "7",
          children: [],
        },
      ],
      menuFlag: "",
    };
  },
  methods: {
    init() {
      // 获取当前角色下的二级列表
      getUserAuthResourceList(this.menuList[0].id).then((res) => {
        if (res.code == 0) {
          this.menuList[0].children = res.data;
          let flag = this.$route.query.flag;
          if (flag) {
            console.log(1111,flag);
            this.menuFlag = String(flag);
          } else {
            console.log(2,res.data[0].id);
            this.menuFlag = res.data[0].id.toString();
          }
        } else {
          this.$message.error(`${res.data}`);
        }
      });
    },
    handleMenu(id) {
      this.menuFlag = id;
    },
    // 获取当前角色下的二级列表
    getUserOnelist() {
      this.checkTree = [];
      let userInfo = sessionStorage.getItem("userInfo");
      this.roleId = JSON.parse(userInfo).roleId;
      getRoleResourceList(this.roleId).then((res) => {
        if (res.code == 0) {
          if (res.data.length > 0) {
            let arr = [];
            res.data.forEach((element, index) => {
              arr.push(element.resourceId);
            });
            this.checkTree = arr;
          } else {
            this.checkTree = [];
          }
        }
      });
    },
  },
  created() {
    bus.$on("setRole", (val) => {
      this.init();
    });
    this.init();
  },
};
</script>

<style scoped>
.roleText {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: orangered;
  font-size: 16px;
}
</style>
